<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Dashboard extends CI_Controller {

  public function __construct()
  {
    parent::__construct();

    // Redirect if user not logged in
    if (!$this->session->userdata('login')) redirect('login');
    
    $this->load->model('guests_model');
  }
  
  // =============================================================================
  
	public function index()
	{
	  $email    = $this->session->userdata('email');
	  $group_id = $this->guests_model->get_user_data('group_id', $email);
	  
		$data['page_title'] = title('Dashboard');
		
		$data['name']    = $this->guests_model->get_user_data('name', $email);
		$data['balance'] = $this->guests_model->get_user_data('balance', $email);
		$data['camping'] = $this->guests_model->get_user_data('is_camping', $email) ? 'Yes' : 'No';
		$data['ticket']  = $this->guests_model->get_user_data('guest_id', $email);
		$data['group']   = $this->guests_model->get_user_group($group_id, $email);
		
		$this->load->view('templates/header', $data);
		$this->load->view('dashboard/dashboard_view', $data);
		$this->load->view('templates/footer', $data);
	}
}

// End of File